//
// Header
//

._header {
  position: absolute;
  z-index: $headerZ;
  top: 0;
  left: 0;
  display: -ms-flexbox;
  display: flex;
  width: $sidebarWidth;
  height: $headerHeight;
  background: $headerBackground;
  border-bottom: 1px solid $headerBorder;
  border-right: 1px solid $headerBorder;
  @extend %border-box;
  @extend %user-select-none;

  @media #{$mediumScreen} { width: $sidebarMediumWidth; }
}

._header-left {
  float: left;
  height: 100%;
}

._header-right {
  float: right;
  height: 100%;
}

._header-btn {
  position: relative;
  flex: 0 0 auto;
  width: 2.25rem;
  height: 100%;
  color: $textColorLight;
  text-align: center;

  &[hidden] { display: none; }

  &[disabled] {
    opacity: .3;
    cursor: not-allowed;
  }

  > svg {
    display: inline-block;
    vertical-align: top;
    width: 1.5rem;
    height: 1.5rem;
    fill: currentColor;
    pointer-events: none;
  }
}

//
// Menu
//

._menu {
  position: absolute;
  z-index: 1;
  top: .25rem;
  right: .25rem;
  width: 8.5rem;
  height: calc(13.75rem + 1px);
  white-space: nowrap;
  word-wrap: normal;
  overflow-wrap: normal;
  font-size: .875rem;
  background: $contentBackground;
  border: 1px solid $headerBorder;
  border-radius: 3px;
  box-shadow: -1px 1px 1px rgba(black, .05);
  transition: all 250ms cubic-bezier(0.23, 1, 0.32, 1);
  opacity: 0;
  -webkit-transform: scale(0, 0);
          transform: scale(0, 0);
  -webkit-transform-origin: 100% 0;
          transform-origin: 100% 0;

  &:hover,
  ._menu-btn:hover + & {
    transition-delay: 100ms;
  }

  &:hover,
  &.active,
  ._menu-btn:hover + &,
  ._menu-btn:focus + & {
    opacity: 1;
    -webkit-transform: scale(1, 1);
            transform: scale(1, 1);
  }

  &:focus-within {
    opacity: 1;
    -webkit-transform: scale(1, 1);
            transform: scale(1, 1);
  }
}

._menu-title {
  margin: 0;
  line-height: 1.5rem;
  font-size: 1rem;
  font-weight: $boldFontWeight;
  letter-spacing: -.5px;
  background: $sidebarBackground;
  border-bottom: 1px solid $sidebarBorder;
  border-radius: 2px 2px 0 0;
}

._menu-title-link,
._menu-title-link:hover {
  display: block;
  padding: .5rem 1rem;
  color: $focusText;
  text-decoration: none;
}

._menu-link {
  display: block;
  padding: 0 1rem;
  line-height: 2.25rem;
  color: inherit;
  text-decoration: none;

  &:hover {
    color: $focusText;
    text-decoration: none;
    background: $sidebarBackground;
  }

  &:last-child { border-radius: 0 0 2px 2px; }
}

//
// Search form
//

._search {
  -ms-flex: 1 1 auto;
      flex: 1 1 auto;
  position: relative;
  height: 100%;
  padding: .5rem 0 .5rem .5rem;
  @extend %border-box;

  &:before {
    position: absolute;
    z-index: 1;
    top: calc(1rem - 1px);
    left: 1rem;
    opacity: .4;
    pointer-events: none;
    @if $style == 'dark' {
      @extend %icon, %icon-search-white;
    } @else {
      @extend %icon, %icon-search;
    }
  }
}

._search-input {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0 .75rem 1px 1.75rem;
  font-size: .875rem;
  background: $contentBackground;
  border: 1px solid;
  border-color: darken($headerBorder, 2%);
  border-radius: 3px;

  &:focus {
    outline: 0;
    @if $inputFocusBorder {
      border-color: $inputFocusBorder;
      box-shadow: 0 0 1px $inputFocusBorder;
    }
  }

  &[disabled] {
    background: $sidebarBackground;
    cursor: not-allowed;
  }
}

._search-clear {
  display: none;
  position: absolute;
  top: .5em;
  right: 0;
  width: 2rem;
  height: 2rem;
  opacity: .3;
  @extend %hide-text;

  &:hover { opacity: .5; }

  &:before {
    position: absolute;
    top: .5rem;
    left: .5rem;
    @extend %icon;
  }

  @if $style == 'dark' {
    &:before { @extend %icon-close-white; }
  } @else {
    &:before { @extend %icon-clear; }
  }
  ._search-active > & { display: block; }
}

._search-tag {
  display: none;
  position: absolute;
  z-index: 2;
  top: .875rem;
  left: .875rem;
  padding: 0 .375rem;
  line-height: 1.25rem;
  max-width: 50%;
  font-size: .8125rem;
  color: $textColorLight;
  background: darken($headerBackground, 5%);
  border-radius: 2px;
  @extend %truncate-text;
}
